package com.chat.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
public class MyUtil {
	public static void main(String[] args) {
		String orderDate = getCreateTime();
		System.out.println("orderDate:" + orderDate);
	}
	public static String orderDate() {
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd");
		String format = sdf.format(date);
		return format;
	}
	public static String getCreateTime() {
		return new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date());
	}
	public static String getYear() {
		Date date = new Date();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
		String format = sdf.format(date);
		return format;
	}
	public static Object orderTime() {
		Date date = new Date();
		int h = Integer.parseInt(new SimpleDateFormat("HH").format(date)) * 60 * 60;
		int m = Integer.parseInt(new SimpleDateFormat("mm").format(date)) * 60;
		int s = Integer.parseInt(new SimpleDateFormat("ss").format(date));
		int total = h + m + s;
		StringBuffer sb = new StringBuffer(total + "");
		if (sb.length() == 1) {
			sb.insert(0, "0000"); 
		}
		if (sb.length() == 2) {
			sb.insert(0, "000"); 
		}
		if (sb.length() == 3) {
			sb.insert(0, "00"); 
		}
		if (sb.length() == 4) {
			sb.insert(0, "0"); 
		}
		return new String(sb);
	}
	public static String getUUid(int num) {
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < num; i++) {
			int index = (int) (Math.random() * 10);
			sb.append(index);
		}
		return sb.toString();
	}
	public static String findnum2() {
		StringBuffer sb = new StringBuffer();
		sb.append(orderDate());
		sb.append(orderTime());
		sb.append(getUUid(4));
		String str = new String(sb);
		return str;
	}
	public static String findnum() {
		StringBuffer sb = new StringBuffer();
		sb.append(orderDate());
		sb.append(orderTime());
		sb.append(getUUid(4));
		String str = new String(sb);
		return str;
	}
	public static String imageName() {
		StringBuffer sb = new StringBuffer();
		sb.append((String) orderDate());
		Date date = new Date();
		String h = new SimpleDateFormat("HH").format(date);
		String m = new SimpleDateFormat("mm").format(date);
		String s = new SimpleDateFormat("ss").format(date);
		sb.append(h);
		sb.append(m);
		sb.append(s);
		sb.append(getUUid(4));
		String imageName = sb.toString();
		return imageName;
	}
	public static String path(String type1) {
		StringBuffer sb = new StringBuffer();
		sb.append("webfile/");
		sb.append(type1 + "/");
		sb.append(getYear() + "/");
		sb.append("image/");
		String path = sb.toString();
		return path;
	}
	public static String integer2Str(Integer index) {
		String str = null;
		if (index == 1) {
			str = "平方";
		} else if (index == 2) {
			str = "米";
		} else if (index == 3) {
			str = "片";
		} else if (index == 4) {
			str = "公斤";
		} else if (index == 5) {
			str = "立方";
		} else if (index == 6) {
			str = "个";
		} else if (index == 7) {
			str = "套";
		} else if (index == 8) {
			str = "条";
		} else if (index == 9) {
			str = "台";
		} else if (index == 10) {
			str = "樘";
		}
		return str;
	}
	public String substring(String str, int start, int end) {
		return null;

	}
}
